<html>
<head><meta charset="utf-8"><title>Detect via cfg · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Detect.20via.20cfg.html">Detect via cfg</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="212859306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Detect%20via%20cfg/near/212859306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Diggsey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Detect.20via.20cfg.html#212859306">(Oct 09 2020 at 18:18)</a>:</h4>
<p>Is there a way to detect RA via a <code>cfg()</code> statement?</p>



<a name="212859344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Detect%20via%20cfg/near/212859344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Diggsey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Detect.20via.20cfg.html#212859344">(Oct 09 2020 at 18:18)</a>:</h4>
<p>I would like to hide some <code>use</code> statements that cause problems for RA</p>



<a name="212859395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Detect%20via%20cfg/near/212859395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Detect.20via.20cfg.html#212859395">(Oct 09 2020 at 18:19)</a>:</h4>
<p>No</p>



<a name="212859422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Detect%20via%20cfg/near/212859422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Detect.20via.20cfg.html#212859422">(Oct 09 2020 at 18:19)</a>:</h4>
<p>Which ones cause issues?</p>



<a name="212859443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Detect%20via%20cfg/near/212859443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Diggsey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Detect.20via.20cfg.html#212859443">(Oct 09 2020 at 18:19)</a>:</h4>
<p>I have two crate features which are mutually exclusive</p>



<a name="212859569"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Detect%20via%20cfg/near/212859569" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Diggsey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Detect.20via.20cfg.html#212859569">(Oct 09 2020 at 18:20)</a>:</h4>
<p>and I want that to be an error if a downstream crate tries to enable both features, but I don't want RA to complain about it whilst I'm developing the crate</p>



<a name="212859648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Detect%20via%20cfg/near/212859648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Detect.20via.20cfg.html#212859648">(Oct 09 2020 at 18:21)</a>:</h4>
<p>You could do something like that once <a href="https://github.com/rust-analyzer/rust-analyzer/pull/6099">https://github.com/rust-analyzer/rust-analyzer/pull/6099</a> lands I think</p>



<a name="212859666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Detect%20via%20cfg/near/212859666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Detect.20via.20cfg.html#212859666">(Oct 09 2020 at 18:21)</a>:</h4>
<p>By having RA always set a specific env var</p>



<a name="212859724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Detect%20via%20cfg/near/212859724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Detect.20via.20cfg.html#212859724">(Oct 09 2020 at 18:22)</a>:</h4>
<p><del><code>rust-analyzer.cargo.allFeatures</code> is disabled these days, shouldn't it avoid that issue?</del></p>
<p>Hmm.</p>



<a name="212859772"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Detect%20via%20cfg/near/212859772" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Diggsey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Detect.20via.20cfg.html#212859772">(Oct 09 2020 at 18:22)</a>:</h4>
<p>I would still like RA to run on both features though</p>



<a name="212859807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Detect%20via%20cfg/near/212859807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Diggsey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Detect.20via.20cfg.html#212859807">(Oct 09 2020 at 18:22)</a>:</h4>
<p>I just want to disable the conflicting <code>use</code> statement</p>



<a name="212860065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Detect%20via%20cfg/near/212860065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Diggsey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Detect.20via.20cfg.html#212860065">(Oct 09 2020 at 18:25)</a>:</h4>
<p>I suppose I could add a feature for RA</p>



<a name="212860086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Detect%20via%20cfg/near/212860086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Diggsey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Detect.20via.20cfg.html#212860086">(Oct 09 2020 at 18:25)</a>:</h4>
<p>and cfg on that</p>



<a name="213020832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Detect%20via%20cfg/near/213020832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Detect.20via.20cfg.html#213020832">(Oct 12 2020 at 10:22)</a>:</h4>
<p>Yeah, adding a feature is the way to go.</p>



<a name="213020869"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Detect%20via%20cfg/near/213020869" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Detect.20via.20cfg.html#213020869">(Oct 12 2020 at 10:23)</a>:</h4>
<p>Should have designed the language such that cfg-ing happens during monomorphisation, but that ship has sailed :)</p>



<a name="213024659"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Detect%20via%20cfg/near/213024659" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Detect.20via.20cfg.html#213024659">(Oct 12 2020 at 11:06)</a>:</h4>
<p>(deleted)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>